package com.tjsinfo.tjsoa.documentationflow.dangweishouwen.bo;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.tjsinfo.tjsoa.Dao.IQbcDao;
import com.tjsinfo.tjsoa.documentationflow.dangweishouwen.dao.ITDangweishouwendengjibuDAO;
import com.tjsinfo.tjsoa.documentationflow.dangweishouwen.vo.TDangweishouwendengjibu;

public class TDangweishouwendengjibuBO implements ITDangweishouwendengjibuBO{
	private ITDangweishouwendengjibuDAO dangweishouwendengjibuDAO;
	private IQbcDao qbcDao;
	
	public IQbcDao getQbcDao() {
		return qbcDao;
	}

	public void setQbcDao(IQbcDao qbcDao) {
		this.qbcDao = qbcDao;
	}

	public ITDangweishouwendengjibuDAO getDangweishouwendengjibuDAO() {
		return dangweishouwendengjibuDAO;
	}

	public void setDangweishouwendengjibuDAO(
			ITDangweishouwendengjibuDAO dangweishouwendengjibuDAO) {
		this.dangweishouwendengjibuDAO = dangweishouwendengjibuDAO;
	}

	public Boolean addTdangweishouwendengjibu(
			TDangweishouwendengjibu dangweishouwendengjibu) {
		// TODO Auto-generated method stub
		try {
			dangweishouwendengjibuDAO.save(dangweishouwendengjibu);
			return true;
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}

	public List<TDangweishouwendengjibu> selectAll() {
		// TODO Auto-generated method stub
		DetachedCriteria criteria = DetachedCriteria.forClass(TDangweishouwendengjibu.class);
		return qbcDao.getCriteria(criteria);
		 
	}

	public TDangweishouwendengjibu selectByDocid(String docid) {
		// TODO Auto-generated method stub
		DetachedCriteria criteria = DetachedCriteria.forClass(TDangweishouwendengjibu.class);
		criteria.add(Restrictions.eq("docid", docid));
		List<TDangweishouwendengjibu> list =  qbcDao.getCriteria(criteria);
		if (list.size() > 0) {
			return list.get(0);
		}
		return null;
	}

	public Boolean updateTdangweishouwendengjibu(
			TDangweishouwendengjibu dangweishouwendengjibu) {
		// TODO Auto-generated method stub
		try {
			dangweishouwendengjibuDAO.merge(dangweishouwendengjibu);
			return true;
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
	
}
